﻿using System;
using System.Linq;
using BattleFury.Lib.Network.Packets;
using System.Collections.Concurrent;
using BattleFury.Lib.ServerPlayer;

namespace BattleFuryGameEngine
{
    public partial class BattleFuryGame
    {
        ConcurrentQueue<IPacket> _incomingPacketQueue = new ConcurrentQueue<IPacket>();
        public void Networking_ReceivePacket(IPacket p)
        {
            _incomingPacketQueue.Enqueue(p);
        }
        public void HandlePacket(IPacket p)
        {
            switch (p.Command)
            {
                case PacketCommand.Move:
                    MovePacket mv = (MovePacket)p;
                    if (_players.Contains(mv.SourceObjectId))
                    {
                        GenericPlayer player = _players.Get(mv.SourceObjectId);
                        player.CurrentMovement = new BattleFury.Lib.Movement(player.Position, mv.Destination)
                        {
                            Velocity = mv.Velocity
                        };
                    }
                    break;
                default:
                    break;
            }

        }
    }
}
